package Demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-12-19
 * Time: 21:27
 */
public class Main {
    public static void main(String args[]) {
        long sum = 0;
        for (int i = 1; i <= 10; i++)
            sum = sum + fact(i);
        System.out.println("1!+2!+...+10!=" + sum);
    }
    public static long fact(int n) {
        if (n == 1) {
            return 1;
        } else if (n > 1 && n <= 10) {
            return fact(n - 1) * n;
        } else {
            return 1;
        }
    }
}

